<template>
	<view class="border-top">
		<view class="mt-5" v-if="u_loadmore">
			<u-loadmore status="loading" icon-type="circle" />
		</view>
		<view v-else>
			<view class="d-flex a-center j-center flex-column">
				<view class="mt-8">
					<image src="../../static/images/wallet/balance.png" class="balance_img" mode=""></image>
				</view>
				<view class="my-2 font-32">可用店铺余额</view>
				<view class="font-big font-weight"><text v-if="earnings.store_account.seller_money">{{earnings.store_account.seller_money}}</text></view>
				<view class="mt-4 font-32 text-666" >不可用店铺余额<text class="text-000 mx-1" v-if="earnings.store_account.frozen_money">{{earnings.store_account.frozen_money}}</text>元</view>
				<view class="font-32 mt-2 text-666">待结算余额<text class="text-000 mx-1" v-if="earnings.store_account.await_settlement_money">{{earnings.store_account.await_settlement_money}}</text>元</view>
				<!-- <view class="withdraw w-100">
					<button type="default" >提现</button>
				</view> -->
				<view class="bg-white withdraw py-2 w-100">
					<button type="warn" @click="withdraw_btn">提现</button>
				</view>
				
				<view class="withdraw_record" @click="record_btn">
					提现记录
				</view>
				
				
				
				<!-- 实名认证弹框 -->
				<u-modal :mask-close-able="true" v-model="withdraw_show" :content="content" :show-title="false" confirm-text="去认证" confirm-color="#ff0000" @confirm="confirm_certification"></u-modal>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data(){
			return {
				withdraw_show:false,
				content:"你的店铺还未通过认证，请先进行身份认证",
				earnings:"", // 掌柜首页统计数据
				u_loadmore:true, // 加载中
			}
		},
		methods:{
			// 实名认证弹框
			withdraw_btn(){
				if(this.earnings.store_account.account_verify_status=="unverify"){
					this.withdraw_show=true
				}else if(this.earnings.store_account.account_verify_status=="agree"){
					uni.navigateTo({
						url:"/pagesA/store/store-withdraw"
					})
				}else if(this.earnings.store_account.account_verify_status=="await_check"||this.earnings.store_account.account_verify_status=="refused"){
					uni.navigateTo({
						url:'/pagesA/store/store-certification-update'
					})
				}
			},
			// 实名认证
			confirm_certification(){
				if(this.earnings.store_account.account_verify_status=="agree"){
					uni.navigateTo({
						url:"/pagesA/store/store-withdraw"
					})
				}else if(this.earnings.store_account.account_verify_status=="refused"||this.earnings.store_account.account_verify_status=="await_check"){
					uni.navigateTo({
						url:"/pagesA/store/store-certification-update"
					})
				}else if(this.earnings.store_account.account_verify_status=="unverify"){
					uni.navigateTo({
						url:"/pagesA/store/store-certification"
					})
				}
			},
			// 提现记录
			record_btn(){
				uni.navigateTo({
					url:"/pagesA/store/store-withdraw-record"
				})
			}
		},
		onLoad() {
			this.$H.post("v2/store/home/data").then(res=>{
				this.earnings=res.data
				this.u_loadmore=false 
			})
		},
		onShow() {
			// HOME数据
			this.$H.post("v2/store/home/data").then(res=>{
				this.earnings=res.data
			})
		}
	}
</script>

<style>
	page{
		background-color: #FFFFFF;
	}
	.balance_img{
		width: 100upx;
		height: 100upx;
	}
	.withdraw{
		margin-top: 120upx;
	}
	.withdraw /deep/ button{
		width: 55%;
		background: linear-gradient(to right,#f84d25,#f5403b);
		color: #FFFFFF;
		border-radius: 50upx;
	}
	
	.withdraw_record{
		color: #FF0000;
		position: absolute;
		bottom: 5%;
	}
</style>
